import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_syt/datas/user_info.dart';
import 'package:flutter_syt/generated/l10n.dart';
import 'package:flutter_syt/routes.all.dart';
import 'package:flutter_syt/theme/font_styles.dart';
import 'package:flutter_syt/theme/theme_color.dart';
import 'package:flutter_syt/utils/click_utils.dart';
import 'package:yyy_route_annotation/yyy_route_annotation.dart';

import '../../global_easy_loading.dart';

@RoutePage(name: "removeAccountNotice")
class RemoveAccountNotice extends StatefulWidget {
  const RemoveAccountNotice();

  @override
  _RemoveAccountNoticeState createState() => _RemoveAccountNoticeState();
}

class _RemoveAccountNoticeState extends State<RemoveAccountNotice> {
  bool _agree = false;

  TextStyle textStyle = FontStyles.headerTextStyle_16.copyWith(
    color: ThemeColor.colorBlack80,
    fontWeight: FontWeight.w300,
  );

  Widget _agreeWidget() {
    return Container(
      margin: EdgeInsets.only(top: 10),
      child: Row(
        mainAxisSize: MainAxisSize.min,
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          IconButton(
            padding: EdgeInsets.symmetric(vertical: 0, horizontal: 0),
            constraints: BoxConstraints(
              minWidth: 20,
              minHeight: 20,
            ),
            icon: Icon(
              _agree
                  ? Icons.radio_button_checked_outlined
                  : Icons.radio_button_unchecked_outlined,
              color: _agree ? ThemeColor.primaryColor : Colors.grey,
              size: 20,
            ),
            onPressed: ClickUtils.debounce(() => {
                  setState(() {
                    _agree = !_agree;
                  })
                }),
          ),
          Expanded(
            child: Container(
              padding: EdgeInsets.only(left: 6),
              // width: 260,
              child: Text.rich(
                TextSpan(children: [
                  TextSpan(
                    text: S.of(context).cancel_check,
                    style: textStyle,
                  ),
                ]),
                textAlign: TextAlign.start,
              ),
            ),
          ),
        ],
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(S.of(context).delete_account_title),
      ),
      body: Column(
        children: [
          Expanded(
              child: SingleChildScrollView(
                  child: Container(
            color: Colors.white,
            padding: EdgeInsets.all(20),
            child: Column(
              children: [
                Container(
                  margin: EdgeInsets.only(bottom: 40),
                  child: RichText(
                    textAlign: TextAlign.left,
                    text: TextSpan(
                      children: [
                        TextSpan(
                            text: UserInfo.me.registerType == '2'
                                ? S.of(context).cancellation_prompt_email
                                : S.of(context).cancellation_prompt),
                        TextSpan(
                          text: '',
                        ),
                      ],
                      style: textStyle,
                    ),
                  ),
                ),
                _agreeWidget(),
              ],
            ),
          ))),
          Container(
            margin: EdgeInsets.only(bottom: 10),
            width: MediaQuery.of(context).size.width,
            padding: EdgeInsets.all(20),
            child: ElevatedButton(
                child: Text(
                  S.of(context).continues,
                  style: TextStyle(fontWeight: FontWeight.bold),
                ),
                onPressed: ClickUtils.debounce(
                  () {
                    if (!_agree) {
                      customShowToast(S.of(context).delete_account_hint);
                      return;
                    }
                    RouteManager.push(
                      context,
                      RoutMapping.removeAccountVerify(),
                    );
                  },
                )),
          )
        ],
      ),
      // body: Stack(
      //   children: [
      //     Container(
      //       color: Colors.white,
      //       padding: EdgeInsets.all(20),
      //       child: Column(
      //         children: [
      //           Container(
      //             margin: EdgeInsets.only(bottom: 40),
      //             child: RichText(
      //               textAlign: TextAlign.left,
      //               text: TextSpan(
      //                 children: [
      //                   TextSpan(
      //                       text: UserInfo.me.registerType == '2'
      //                           ? S.of(context).cancellation_prompt_email
      //                           : S.of(context).cancellation_prompt),
      //                   TextSpan(
      //                     text: '',
      //                   ),
      //                 ],
      //                 style: textStyle,
      //               ),
      //             ),
      //           ),
      //           _agreeWidget(),
      //         ],
      //       ),
      //     ),
      //     Positioned(
      //       bottom: 10,
      //       child: Container(
      //         width: MediaQuery.of(context).size.width,
      //         padding: EdgeInsets.all(20),
      //         child: ElevatedButton(
      //             child: Text(
      //               S.of(context).continues,
      //               style: TextStyle(fontWeight: FontWeight.bold),
      //             ),
      //             onPressed: ClickUtils.debounce(
      //               () {
      //                 if (!_agree) {
      //                   customShowToast(S.of(context).delete_account_hint);
      //                   return;
      //                 }
      //                 RouteManager.push(
      //                   context,
      //                   RoutMapping.removeAccountVerify(),
      //                 );
      //               },
      //             )),
      //       ),
      //     ),
      //   ],
      // ),
    );
  }
}
